package com.jues.huichain.login.presenter;

import com.jues.huichain.login.activity.RegisterActivity2;
import com.jues.huichain.login.entity.EntranceResultEntity;
import com.jues.huichain.login.entity.RegisterBusinessListEntity;
import com.jues.huichain.login.entity.RegisterDepartmentListEntity;
import com.jues.huichain.login.entity.RegisterPositionListEntity;
import com.jues.huichain.login.entity.RegisterRequest;
import com.jues.huichain.login.model.EntranceModel;

import health.lm.com.component_base.base.mvp.contract.XPresent;
import health.lm.com.data.App;
import health.lm.com.network.callback.SimpleCallBack;

/**
 * Created by Android Studio .
 * Project：hlian com.jues.huichain.login.presenter
 * Date：2019/8/7 14:32
 * Introduce：hlian
 */
public class Register2Presenter extends XPresent<RegisterActivity2> {
    public void register(RegisterRequest pRequest) {
//        EntranceEntity entranceEntity = new EntranceEntity(phone, HttpCST.TYPE_REG, code);
//        entranceEntity.setAccess_token("");
//        entranceEntity.setPassword(psw);
//        entranceEntity.setConfirm_password(psw);
//        entranceEntity.setNick_name(username);
//        entranceEntity.setParent_mobile(referrer);
        EntranceModel.getInstance().register(pRequest, new SimpleCallBack<EntranceResultEntity.ResultDataBean>() {
            @Override
            public void onSuccess(EntranceResultEntity.ResultDataBean pResultDataBean) {
                if (hasV()) {
                    getV().registerSuccess("注册成功");
                    //保存用户id
                    App.getModel().setUid(pResultDataBean.getUser_id());
                }
            }
        });
    }

    /**
     * 获取职务数据
     */
    public void getPositionData() {
        EntranceModel.getInstance().getPositionList(new SimpleCallBack<RegisterPositionListEntity>() {
            @Override
            public void onSuccess(RegisterPositionListEntity pRegisterListEntity) {
                if (hasV()) getV().setPositionData(pRegisterListEntity.getDuties_list());
            }
        });
    }

    /**
     * 获取行业数据
     */
    public void getBusinessData(String parent_mobile) {
        EntranceModel.getInstance().getBusinessList(parent_mobile, new SimpleCallBack<RegisterBusinessListEntity>() {
            @Override
            public void onSuccess(RegisterBusinessListEntity pRegisterListEntity) {
                if (hasV()) getV().setBusinessData(pRegisterListEntity.getIndustry_list());
            }
        });
    }

    /**
     * 获取部门数据
     */
    public void getDepartmentData() {
        EntranceModel.getInstance().getDepartmentList(new SimpleCallBack<RegisterDepartmentListEntity>() {
            @Override
            public void onSuccess(RegisterDepartmentListEntity pRegisterListEntity) {
                if (hasV()) getV().setDepartmentData(pRegisterListEntity.getDepartment_list());
            }
        });
    }
}
